let $info = $('.info')

let init = {
  url : 'http://chst.vip:1234/api/getcoupon',
  success : title
}

function title (res){
  let infoStr = ''
  res.result.forEach(element => {
    infoStr += ` 
    <li id=${element.couponId}>   
      <a  href="">
        <img src="${element.couponImg}" alt="">
        <p>${element.couponTitle}</p>
      </a>
    </li>`
  });
  $info.html(infoStr)
}

ajaxAPI(init)

$info.on('click','li',function(e){
  e.preventDefault()
  let id = $(this).attr('id');
  console.log(id);
  window.location.href = './couponitems.html?couponId=' + id;
})